import requests
from bs4 import BeautifulSoup


def hot():
    # 微博热搜榜
    # id = 7
    url = 'https://s.weibo.com/top/summary'
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36 Edg/80.0.361.57'
    }
    response = requests.get(url, headers=headers).text
    soup = BeautifulSoup(response, 'lxml')
    datas = soup.select('#pl_top_realtimehot > table > tbody > tr > td.td-02 > a')
    result = []
    for each in datas:
        result.append([each.text, 'https://s.weibo.com' + each.get('href')])
    print(result)
    return str(result)


if __name__ == '__main__':
    hot()
